package com.atguigu.gulimall.order.feign.fallback;

import com.atguigu.common.exception.BizCodeEnume;
import com.atguigu.common.utils.R;
import com.atguigu.gulimall.order.feign.WmsFeignService;
import com.atguigu.gulimall.order.vo.WareSkuLockVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 库存远程访问错误熔断
 *
 * @author xiaoping
 * @create 2020/7/13 18:55
 * @since 1.0.0
 */
@Slf4j
@Component
public class WareFeignServiceFallBack implements WmsFeignService {

    /**
     * 查询sku是否有库存
     *
     * @param skuIds
     */
    @Override
    public R getSkusHasStock(List<Long> skuIds) {
        log.error("熔断方法调用...getSkusHasStock");
        return R.error(BizCodeEnume.TOO_MANY_REQUEST.getCode(), BizCodeEnume.TOO_MANY_REQUEST.getMsg());
    }

    /**
     * 根据地址获取运费信息
     *
     * @param addrId
     * @return
     */
    @Override
    public R getFare(Long addrId) {
        log.error("熔断方法调用...getFare");
        return R.error(BizCodeEnume.TOO_MANY_REQUEST.getCode(), BizCodeEnume.TOO_MANY_REQUEST.getMsg());
    }

    /**
     * 锁定订单库存
     *
     * @param vo
     * @return
     */
    @Override
    public R orderLockStock(WareSkuLockVo vo) {
        log.error("熔断方法调用...orderLockStock");
        return R.error(BizCodeEnume.TOO_MANY_REQUEST.getCode(), BizCodeEnume.TOO_MANY_REQUEST.getMsg());
    }
}
